package com.tanhua.server.controller;

import com.tanhua.model.vo.UserInfoVo;
import com.tanhua.model.vo.VoiceVo;
import com.tanhua.server.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author lamy
 * @version 1.0
 * @ClassName: VoiceController
 * @date 2021-12-26 10:24:07
 */
@RestController
@RequestMapping("/peachblossom")
public class VoiceController {

    @Autowired
    private VoiceService voiceService;

    /**
     * 桃花传音-发送语音
     * @param soundFile 语音文件
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public ResponseEntity sendVoice(@RequestBody MultipartFile soundFile){
        voiceService.sendVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public ResponseEntity getVoice(){
        VoiceVo voiceVo = voiceService.getVoice();
        return ResponseEntity.ok(voiceVo);
    }
}
